<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <!-- metas -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="<?=BASEURL.CSS_DIR?>style_edit.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="<?=BASEURL.CSS_DIR?>popin.css" media="screen"/>
    <!-- javascript -->
    <script type="text/javascript" src="<?=BASEURL.JS_DIR?>jquery.js" ></script>
    <script type="text/javascript" src="<?=BASEURL.JS_DIR?>jquery_std.js" ></script>
    <script type="text/javascript" src="<?=BASEURL.JS_DIR?>common.js" ></script>
    <script type="text/javascript" src="<?=BASEURL.JS_DIR?>popin.js" ></script>
    <script type="text/javascript" src="<?=BASEURL.JS_DIR?>toolbar.js" ></script>
    <script type="text/javascript">
    
    //data from server
    myData = {};
    myData.baseUrl  = "<?=site_url('');?>";
    myData.isLogged = <?=@$isLogged+0?>;

    
    function normalize_str(raw)
    {
        var search_str  = " .ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ";
        var replace_str = "__aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyyby";
        var norm=raw.toLowerCase();
        for (var i=0;i<search_str.length;i++) {
            norm = norm.replace(search_str.charAt(i),replace_str.charAt(i),"g");
        }
        norm = norm.replace(/[^a-zA-Z0-9-_]/, "");
        return norm;
    }
    
    function site_url(url)
    {
        return myData.baseUrl+url; 
    }
    
    function update_list()
    {
        $("#list").load(site_url('/admin/gallerymgr/listgals/'),{ajax:"true"},wire_list);
    }

    galSelected=null;
    function wire_list()
    {
        $("input[@type='radio']").click(function(){
            $("#gallerylist li").removeClass("selected");
            $(this).parent('li').addClass("selected");
            galSelected=$(this).val();
        });
    
    }


    $(document).ready(function() {
       //buttons & selects
       
       $("#btLogout").click(function(){
            logout(site_url('/wiki/read/<?=@$pagename;?>')); 
       });
       
       $('#btHelp').click( function(){
            popIn(400,500,site_url('/wiki/readpart/help'),'HELP');
       });
       
       $('#btCreateGal').click( function(){
               var nomgal = normalize_str(prompt("New gallery name:"));
               if (nomgal != null) 
                    $.post(site_url('/admin/gallerymgr/addgal/'+nomgal),{ajax:"true"},update_list);
                   
       });
       
       $('#btDeleteGal').click( function(){
              if (confirm ("are you sure ?"))
                  $.post(site_url('/admin/gallerymgr/delgal/'+galSelected),{ajax:"true"},update_list);
       });
       
       update_list();
    });
    
    </script>
    <title>Nimwiki :: galleries</title>
  </head>
  <body>
<div id="page" >
    <div id="top">
        <span style="float:right;padding-top:11px;" >
            <a href="#" id="btLogout">logout</a>
        </span>
        <span id="logo">
            <img src="<?=BASEURL.IMG_DIR?>logo.gif" />
        </span>
        <span id="titre">
            List galleries
        </span> 
    </div><!-- end div top -->
    <div id="edit">
    <div class="toolbar">
        <a href="#" class="button" id="btCreateGal" >create gallery</a><a href="#" class="button" id="btDeleteGal" >delete gallery</a>
    </div>
        <div id="list"></div>
    </div>
</div>
</body>
</html>
